<?php

// Bootstrap file for getting the ABSPATH constant to wp-load.php
require_once('config.php');

// check for rights
if ( !is_user_logged_in() || !current_user_can('edit_posts') ) 
	wp_die(__("You are not allowed to be here"));
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><?php echo $themename .' Shortcode'; ?></title>
	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
	<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
	<script language="javascript" type="text/javascript" src="<?php echo get_template_directory_uri() ?>/lib/admin/tinymce/tinymce.js"></script>
	<base target="_self" />
</head>
<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('portfolio_category').focus();" style="display: none">
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
	<form name="webtreats_portfolio" action="#">
	<div class="tabs">
		<ul>
			<li id="style_tab" class="current"><span><a href="javascript:mcTabs.displayTab('style_tab','style_panel');" onmousedown="return false;">Styles Shortcodes</a></span></li>
			<li id="portfolio_tab"><span><a href="javascript:mcTabs.displayTab('portfolio_tab','portfolio_panel');" onmousedown="return false;">Portfolio</a></span></li>
			<li id="contact_tab"><span><a href="javascript:mcTabs.displayTab('contact_tab','contact_panel');" onmousedown="return false;">Contact Form</a></span></li>
		</ul>
	</div>
	
	<div class="panel_wrapper" style="height:175px;">
		
		
		
			<!-- style_panel -->
			<div id="style_panel" class="panel current">
			<br />
			<fieldset>
				<legend>Select the style shortcode you would like to insert into the page</legend>
			<table border="0" cellpadding="4" cellspacing="0">
	         <tr>
	            <td nowrap="nowrap"><label for="style_shortcode">Select Custom Style:</label></td>
	            <td><select id="style_shortcode" name="style_shortcode" style="width: 200px">
	                <option value="0">No Style</option>
					<?php
					if(is_array($shortcode_tags)) {
						$i=1;
						foreach ($shortcode_tags as $webtreats_sc_key => $webtreats_sc_value) {
							if( stristr($webtreats_sc_value, 'webtreats') ) {

								$webtreats_sc_name = str_replace('webtreats_', '' ,$webtreats_sc_value);
								$webtreats_sc_name = str_replace('_sc', '' ,$webtreats_sc_name);
								$webtreats_sc_name = str_replace('_', ' ' ,$webtreats_sc_name);

								if($i==1){ echo '<optgroup label="Widget Shortcodes">'; }
								if($i==8){ echo '<optgroup label="Image Shortcodes">'; }
								if($i==13){ echo '<optgroup label="Style Shortcodes">'; }
								if($i==52){ echo '<optgroup label="Column Shortcodes">'; }


								$webtreats_sc_name = ucwords($webtreats_sc_name);
								echo '<option value="' . $webtreats_sc_key . '" >' . $webtreats_sc_name . '</option>' . "\n";


								if($i==7){ 
									echo '</optgroup>';
									echo '<optgroup label="Video">';
									echo '<option value="youtube" >YouTube</option>' . "\n";
									echo '<option value="vimeo" >Vimeo</option>' . "\n";
									echo '</optgroup>'; 
									}
								if($i==12){ echo '</optgroup>'; }
								if($i==51){ 
									echo '</optgroup>'; 
									echo '<optgroup label="Layout Shortcodes">';
									echo '<option value="one_half_layout" >Two Column Layout</option>' . "\n";
									echo '<option value="one_third_layout" >Three Column Layout</option>' . "\n";
									echo '<option value="one_fourth_layout" >Four Column Layout</option>' . "\n";
									echo '<option value="one_fifth_layout" >Five Column Layout</option>' . "\n";
									echo '<option value="one_sixth_layout" >Six Column Layout</option>' . "\n";
									echo '<option value="one_third_two_third" >One Third - Two Third</option>' . "\n";
									echo '<option value="two_third_one_third" >Two Third - One Third</option>' . "\n";
									echo '<option value="one_fourth_three_fourth" >One Fourth - Three Fourth</option>' . "\n";
									echo '<option value="three_fourth_one_fourth" >Three Fourth - One Fourth</option>' . "\n";
									echo '<option value="one_fourth_one_fourth_one_half" >One Fourth - One Fourth - One Half</option>' . "\n";
									echo '<option value="one_fourth_one_half_one_fourth" >One Fourth - One Half - One Fourth</option>' . "\n";
									echo '<option value="one_half_one_fourth_one_fourth" >One Half - One Fourth - One Fourth</option>' . "\n";
									echo '<option value="four_fifth_one_fifth" >Four Fifth - One Fifth</option>' . "\n";
									echo '<option value="one_fifth_four_fifth" >One Fifth - Four Fifth</option>' . "\n";
									echo '<option value="two_fifth_three_fifth" >Two Fifth - Three Fifth</option>' . "\n";
									echo '<option value="one_sixth_five_sixth" >One Sixth - Five Sixth</option>' . "\n";
									echo '<option value="five_sixth_one_sixth" >Five Sixth - One Sixth</option>' . "\n";
									echo '<option value="one_sixth_one_sixth_one_sixth_one_half" >One Sixth - One Sixth - One Sixth - One Half</option>' . "\n";

									echo '</optgroup>'; 
								}
								if($i==73){ echo '</optgroup>'; }

								$i++;
							}
						}
					} ?>
	            </select></td>
	          </tr>
	        </table>
			</fieldset>
			</div>
		
		
		
		<!-- portfolio_panel -->
		<div id="portfolio_panel" class="panel">
		<br />
		<fieldset>
			<legend>Select the category & attribute settings below for your portfolio</legend>
		<table border="0" cellpadding="4" cellspacing="0">
         <tr>
            <td nowrap="nowrap"><label for="portfolio_category">Select category</label></td>
            <td><select id="portfolio_category" name="portfolio_category" style="width: 200px">
                <option value="0">No Category</option>
				<?php
				/* Get Categories into a drop-down list */
				$webtreats_categories_obj = get_categories('hide_empty=0');
				$webtreats_categories = array();
				$webtreats_categories[] = '';
				foreach ($webtreats_categories_obj as $webtreats_cat) {
					$webtreats_categories[$webtreats_cat->cat_ID] = $webtreats_cat->cat_name;
				}
					if(is_array($webtreats_categories)) {
						foreach($webtreats_categories as $webtreats_catid => $webtreats_catname) {
							if ($webtreats_catname !='') {
								echo '<option value="' . $webtreats_catid . '" >' . $webtreats_catid . ' - ' . $webtreats_catname . '</option>' . "\n";
							}
						}
					} ?>
            </select></td>
          </tr>
          <tr>
            <td nowrap="nowrap" valign="top"><label for="portfolio_columns">Number of columns <br />(max is 4)</label></td>
            <td><input type="text" id="portfolio_columns" name="portfolio_columns" value="3"/><br /></td>
          </tr>
           <tr>
            <td nowrap="nowrap" valign="top"><label for="portfolio_max">Images per page <br />(default is 9)</label></td>
            <td><input type="text" id="portfolio_max" name="portfolio_max" value="9"/><br /></td>
          </tr>
          <tr>
            <td nowrap="nowrap" valign="top"><label for="showtype">Image links to </label></td>
            <td><label><input name="showtype" type="radio" value="image" checked="checked" /> Thickbox Pop-up</label><br />
			<label><input name="showtype" type="radio" value="post" /> Post</label></td>
          </tr>
        </table>
		</fieldset>
		</div><!-- portfolio_panel -->
		
		
		
		<!-- contact_panel -->
		<div id="contact_panel" class="panel">
		<br />
		<fieldset>
			<legend>Enter your email address for the contact form below</legend>
		<table border="0" cellpadding="4" cellspacing="0">
          <tr>
            <td nowrap="nowrap"><label for="contact_email">Email Address:</label></td>
            <td><input type="text" id="contact_email" name="contact_email" size="44" /><br /></td>
          </tr>
        </table>
		</fieldset>
		</div><!-- contact_panel -->
	</div>

	<div class="mceActionPanel">
		<div style="float: left">
			<input type="button" id="cancel" name="cancel" value="<?php echo "Cancel"; ?>" onclick="tinyMCEPopup.close();" />
		</div>

		<div style="float: right">
			<input type="submit" id="insert" name="insert" value="<?php echo "Insert"; ?>" onclick="insertWebtreatsLink();" />
		</div>
	</div>
</form>
</body>
</html>
